<template>
  <div class="me-redact">
    <!-- 基本资料 -->
    <el-form  :model="formData" :rules="basicRules" ref="basicForm" label-width="184px" class="demo-formData">
      <p class="secTitle">
        <span class="secTitle-text">基本信息</span>
        <span class="redact-text" @click="updateBasic('formData')">{{needSupplyInfo!==0 ? '保存并返回支付':'保存'}}</span>
      </p>
      <div class="formSection">
        <!-- 头像 -->
        <div class="avatarContent">
          <div class="avatar-div">
            <img :src="formData.avatar" @click="showPhotoLog"/>
          </div>
          <p class="avatar-change">点击头像修改</p>
          <p class="avatar-text">支持jpg、jpeg、gif、png或bmp格式的图片，文件大小不超过2M</p>
          <el-dialog title="上传头像" :visible.sync="picVisible">
            <div class="dialog-pic">
              <div id="my-pic-avatar">
                <div class="pic-store">
                  <img class="avatar-photo" v-for="(item, index) of currentPhotoList" :src="'static'+item" :key="index" @click="toggleAvatar(item)"/>
                </div>
                <div class="pagination">
                  <span style="padding-right: 10px;font-size: 20px;cursor: pointer;" @click="togglePhotoList(0)">&lt;</span>
                  <span style="margin: 0 15px;">
                    <b style="font-size: 22px;color: #FF6252;">{{currentPhotoPage+1}}</b>/{{totlaPage+1}}
                  </span>
                  <span style="padding-left: 10px;font-size: 20px;cursor: pointer;" @click="togglePhotoList(1)">&gt;</span>
                </div>
              </div>
              <div class="pic-content">
                <div class="content-avatar">
                  <!-- <cropper v-if="avatarIsHttp"
                    ref="cropper"
                    :img="temporaryUrl"
                    :autoCrop="example.autoCrop"
                    :canScale="example.canScale"
                    :canMove="example.canMove"
                    :centerBox="example.centerBox"
                    :autoCropWidth="example.autoCropWidth"
                    :autoCropHeight="example.autoCropHeight"
                    :fixed="example.fixed"
                    @cropMoving="creatImg"
                  >
                  </cropper> -->
                  <!-- <img src="" alt=""> -->
                  <img :src="temporaryUrl"/>
                  <input @click="clearFile" @change="pickAva" type="file" name="file" class="imgInput">
                </div>
                <div class="my-upload">
                  <div class="pic-select-text">选择文件</div>
                  <p class="avatarNotice">
                  <span ref="avatarText" class="avatarText">{{avaNotice.text}}</span>
                  </p>
                  <label class="my-upload-input" for="avatorImage">
                    <input class="fileInput" @click="clearFile" @change="pickAva" type="file" id="avatorImage" name="file">
                  </label>
                </div>
              </div>
              <div class="preview">
                <img :src="previewUrl" />
                <p>头像预览</p>
              </div>
            </div>
            <el-row class="pic-confim">
              <el-button class="pic-cencle" @click="cenclePhotoLog">取消</el-button>
              <el-button class="pic-seve" @click="confimPhoto">确定</el-button>
            </el-row>
          </el-dialog>
        </div> 
        <!-- 昵称 -->
        <el-form-item label="昵称" prop="nickname">
          <el-input @change="checkNickNameFn" v-model="formData.nickname" placeholder="给自己取个响亮的名字"></el-input>
          <p class="notice">2-12个中英文字符</p>
          <p class="nickNotice">
            <span ref='nickDataText' :class='!nickData.bool ? "on" : "off"'>{{nickData.text}}</span>
         </p>
        </el-form-item>
        <!-- 生日 -->
        <el-form-item class="birthdayClass" label="生日">
          <el-radio-group  v-model="birType" @change="changeBirthType">
            <el-radio  label="0">公历</el-radio>
            <el-radio  label="1">农历</el-radio>
          </el-radio-group>
          <div class="birth-content">
            <el-form-item prop="year">
              <el-select v-model="year" placeholder="年" class="birthday-year" @change="changeYear">
                <el-option v-for="(item,index) in yearList" :key="index" class="textIndent" :label="item" :value="item.toString()"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="month">
              <el-select v-model="month" placeholder="月" class="birthday-month" @change="changeMonth">
                <el-option v-for="(item,index) in monthList" :key="index" class="textIndent" :label="item" :value="item.toString()"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item prop="day">
              <el-select v-model="day" placeholder="日" class="birthday-day" @change="changeDay">
                <el-option v-for="(item,index) in dayList" :key="index" class="textIndent" :label="item" :value="item.toString()"></el-option>
              </el-select>
            </el-form-item>
            <p class="birthday-waring" v-show="birthFlow">日期超过今天了，请重新选择</p>
          </div>
        </el-form-item>
        <!-- 性别 -->
        <el-form-item class="sexClass" label="性别" prop="sex">
          <el-radio-group  v-model="formData.sex">
            <!-- 选择性别后不让再选的函数@click.native="sexDisable" -->
            <el-radio  :disabled='sexCheckBool' label="0">男</el-radio>
            <el-radio  :disabled='sexCheckBool' label="1">女</el-radio>
          </el-radio-group>
          <p class="sexNotice">
            <span ref="noticeText" class="noticeText">请选择性别</span>
          </p>
          <p class="notice sex-notice">保存后不可更改，要认真选择哦~</p>
        </el-form-item>
        <!-- 证书 -->
        <el-form-item class="certificate" label="证书" v-if="currentUser.type!='0'">
          <div class="curriculum-redact">
            <div class="curriculum-add" v-loading="certificateLoading">
              <input @change="addCurriculum('certificate')" type="file" name="file">
              <span class="icon-tianjiatupian"></span>
              <p>点击添加证书</p>
              <span class="curriculum-add-text">支持jpg、jpeg、gif、png或bmp格式的图片 文件大小不超过2M</span>
            </div>
            <el-form-item class="curriculum-item" v-for="(item, index) in formData.certificateList" :key="index+'certificate'"
              :prop="`certificateList[${index}].type`"
              :rules="{
                required: true, message: '', min: 2, max: 30,trigger: 'blur'
              }"
            >
              <span class="icon-sanchutupian" @click="removeCertificate(index)">
                <span class="path1"></span><span class="path2"></span>
              </span>    
              <img :src="item.url" @click="bigPhotoLog(item.url)">
              <div class="certificate-input">
                <el-input v-model="item.type" placeholder="证书名称2-30个字符"></el-input>
              </div>
            </el-form-item>
          </div>
        </el-form-item>
      </div>
    </el-form>
    <!-- 联系信息 -->
    <el-form  :model="formData" :rules="contactRules" ref="contactForm" label-width="184px" class="demo-formData">
      <p class="secTitle">
        <span class="secTitle-text">联系信息</span>
        <span class="redact-text" @click="updateContact('formData')">{{needSupplyInfo!==0 ? '保存并返回支付':'保存'}}</span>
      </p>
      <div class="formSection">
        <!-- 照片 -->
        <el-form-item :class="{'picContent-lable':needSupplyInfo==2}" label="照片" v-if="formData.picture">
          <div  class="picContent middle">
            <!-- <div v-show='(currentUser.type === "0" && needSupplyInfo)||(currentUser.type==="1")' class="picture"> -->
            <div class="picture">
              <!-- <p class="title"><span class="star">*</span>照片</p> -->
              <img class="my-avatar" :src="formData.picture" />
              <!-- <img src="../../../static/add.png" /> -->
              <p class="pic-text">支持jpg、jpeg、gif、png或bmp格式的图片，文件大小不超过2M</p>
              <span class="amend">点击头像修改</span>
            </div>
            <p class="pictureNtice">
              <span ref="pictureText" class="pictureText">{{picNotice.text}}</span>
            </p>
            <div class="uploadBtn middleBtn">
                <div class="uploadBtn">
                  <label class="upload-label" for="chooseImage">
                    <input class="upload-input" @change="pickPic" type="file" id="chooseImage" name="file">
                  </label>
              </div>
            </div>
          </div>
        </el-form-item>
        <!-- 真是姓名 -->
        <el-form-item label="真实姓名" prop="name" style='padding-bottom: 0;'>
          <!-- :disabled='formData.name || (formData.name && currentUser.type==="1")' -->
          <el-input :disabled='nameDisabledFn' v-model="formData.name"></el-input>
          <p class="notice">用于高等教育课程证书登记与发放，不会以任何形式向第三方透露</p>
        </el-form-item>
        <!-- 常用邮箱 -->
        <el-form-item label="常用邮箱" class="emailCheck-wrapper">
          <el-input ref='emailDom' @focus="focusInp" @blur="emailBlur" @keyup.native='emailInp($event)' v-model="formData.email"></el-input>
          <a v-if='showEmailBtnBool' @click='goCheckPage' class="emailCheck" :class="emailCheck.canClick!= 0 && 'on' || ''" href="javascript:;">立即验证</a>
          <span v-if='!showEmailBtnBool' class="authenticated">已验证</span>
          <a v-if='!showEmailBtnBool' @click.stop="revampEmail" class="revamp" href="javascript:;">修改邮箱</a>
          <p class="notice emailNotice" :class="emailCheck.className">{{emailCheck.emailNotice}}</p>
        </el-form-item>
        <!-- 手机号码 -->
        <el-form-item label="手机号码" prop="phone">
          <!-- <el-input :disabled='true' v-model="formData.phone"></el-input> -->
          <p class="fixedPhone" v-text="myphone">123456789</p>
          <p class="notice phone-notice">用于登录账号、接收订单提醒，优惠活动信息，手机号不会对外公开，请放心</p>
        </el-form-item>
        <!-- 身份证 -->
        <el-form-item  class="id-card"  v-if='needSupplyInfo==2 || (formData.idCard && formData.idCard != "")' label="身份证号码" :prop='needSupplyInfo==2||(currentUser.type != "0") ? "idCard":""'>
          <el-input v-if='needSupplyInfo==2'  @keyup.native='limit("idCard", 18)' v-model="formData.idCard"></el-input>
          <p class="fixedPhone" v-else v-text="myIdCard">123456789</p>
        </el-form-item>
        <!-- QQ -->
        <el-form-item class="id-card" label="QQ号码" prop="QQ">
          <el-input @keyup.native='limit("QQ", 18)' v-model="formData.QQ" placeholder="请输入常用QQ 5-18位"></el-input>
        </el-form-item>
      </div>
    </el-form>
    <!-- 学校信息 -->
    <el-form  :model="formData" :rules="schoolRules" ref="schoolForm" label-width="184px" class="demo-formData">
      <p class="secTitle">
        <span class="secTitle-text">学校信息</span> 
        <span class="redact-text" @click="updateSchool('formData')">{{needSupplyInfo!==0 ? '保存并返回支付':'保存'}}</span> 
      </p>
      <div class="formSection">
        <!--城市-->
        <el-form-item label="城市" prop="city">
          <el-select v-model="formData.city" placeholder="请选择城市" @change="changeCity">
            <el-option class="textIndent" v-for="(item, index) of cityListAll" :label="item.cityName" :value="item.id.toString()" :key="index"></el-option>
            <el-option class="textIndent" label="其他" value="-1"></el-option>
            <!-- <el-option label="学校二" value="beijing"></el-option> -->
          </el-select>
        </el-form-item>
        <!--学校-->
        <el-form-item label="学校名称" prop="school" v-if="formData.identity!='2'">
          <el-select v-model="formData.school" placeholder="请选择学校" @change="changeSchool" @visible-change="te('schoolList','area')">
            <div class="search-input"><el-input
              placeholder="请输入学校"
              prefix-icon="el-icon-search"
              v-model="searchKey"
              @input="setFilter('schoolList','area')"
            >
            </el-input></div>
            <el-option class="textIndent" v-for="(item, index) of schoolList" :label="item.area" :value="item.id.toString()" :key='index + "school"' v-show="!item.filterResult"></el-option>
             <div class="no-data" v-show="noData">暂无结果</div>
             <el-option class="textIndent" label="其他" value="-1"></el-option>
          </el-select>
        </el-form-item>
        <!--学院-->
        <el-form-item label="学院名称" prop="college" v-if="formData.identity!='2'">
          <el-select v-model="formData.college" placeholder="请选择学院"   @change="changeCollege" @visible-change="te('collegeList','instituteName')">
            <div class="search-input"><el-input
              placeholder="请输入学院"
              prefix-icon="el-icon-search"
              v-model="searchKey"
              @input="setFilter('collegeList','instituteName')"
            >
            </el-input></div>
            <el-option class="textIndent" v-for="(item, index) of collegeList" :label="item.instituteName" :value="item.id.toString()" :key='index + "collegeList"' v-show="!item.filterResult"></el-option>
            <el-option class="textIndent" label="其他" value="-1"></el-option>
            <div class="no-data" v-show="noData">暂无结果</div>
          </el-select>
        </el-form-item>
        <!--专业-->
        <el-form-item label="专业" prop="major" v-if="formData.identity!='2'">
          <el-select v-model="formData.major" placeholder="请选择专业"  @change="changeMajor" @visible-change="te('majorList','majorName')">
            <div class="search-input"><el-input
              placeholder="请输入专业"
              prefix-icon="el-icon-search"
              v-model="searchKey"
              @input="setFilter('majorList','majorName')"
            >
            </el-input></div>
            <el-option class="textIndent" v-for="(item, index) of majorList" :label="item.majorName" :value="item.id.toString()" :key='index + "major"' v-show="!item.filterResult"></el-option>
            <el-option class="textIndent" label="其他" value="-1"></el-option>
            <div class="no-data" v-show="noData">暂无结果</div>
          </el-select>

        </el-form-item>
        <!--年级-->
        <el-form-item label="年级" prop="grade" v-if="formData.identity!='2'">
          <el-select v-model="formData.grade" placeholder="请选择年级">
            <el-option v-for="(item,index) in gradeArr" :key="index" class="textIndent" :label="item" :value="item"></el-option>
          </el-select>
        </el-form-item>
        <!-- 学历 -->
        <el-form-item label="学历" prop="education" v-if="formData.identity!='2'">
          <el-select v-model="formData.education" placeholder="请选择学历">
            <el-option v-for="(item, index) in educationArr" :key="index+'education'" class="textIndent" :label="item.label" :value="item.value"></el-option>
            <!-- <el-option class="textIndent" label="其他" value="-1"></el-option> -->
          </el-select>
        </el-form-item>
        <!-- 课表 -->
        <el-form-item class="curriculum" label="课表" v-if="currentUser.type!='0' && formData.identity!='2'">         
          <div class="curriculum-redact">
            <div class="curriculum-add" v-loading="curriculumLoading">
              <input @change="addCurriculum('curriculum')" type="file" name="file">
              <span class="icon-tianjiatupian"></span>
              <p>点击添加课表</p>
              <span class="curriculum-add-text">支持jpg、jpeg、gif、png或bmp格式的图片 文件大小不超过2M</span>
            </div>
            <el-form-item class="curriculum-item" v-for="(item, index) in formData.curriculumList" :key="index+'curriculum'"
                :prop="`curriculumList[${index}].semester`"
                :rules="{
                  required: true, message: '', trigger: 'change'
                }"
            >
              <span class="icon-sanchutupian" @click="removeSemester(index)">
                <span class="path1"></span><span class="path2"></span>
              </span>  
              <img :src="item.picture" @click="bigPhotoLog(item.picture)">
              <div class="semester-select">
                <el-select v-model="item.semester" @change="changeSemester($event,index)" placeholder="请选择学期">
                  <el-option v-for="(childItem, childIndex) in semesterList" :key="childIndex+'semester'" class="textIndent" :label="childItem.label" :value="childItem.value.toString()"></el-option>
                </el-select>
              </div>
              
            </el-form-item>
            
          </div>
        </el-form-item>
        <!-- 可接受项目 -->
        <el-form-item class="take-projiect" label="可接受项目" v-if="currentUser.type!='0' && formData.identity!='2'">
            <el-radio-group  v-model="formData.projectCycle">
              <el-radio  label="0">长期</el-radio>
              <el-radio  label="1">短期</el-radio>
            </el-radio-group>
        </el-form-item>
      </div>
    </el-form>
    <el-dialog class="big-photo-log" title="" :visible.sync="bigPhoto" center element-loading-background="rgba(0, 0, 0, 0.4)" >
        <div class="big-photo-content">
          <img :src="bigPhotoSrc">
        </div>
      </el-dialog>
  </div>
</template>

<style lang="stylus" scoped>
@import '~style/base.styl';

.me-redact{
  width: 100%;
  background:rgba(245,245,245,1);
  padding-top: 60px;
  padding-bottom: 90px;
}
.demo-formData{
  width: 1200px;
  margin: 0 auto;
}
.avatarContent{
  margin-bottom: 60px;
}
.avatar-div{
  text-align: center;
  margin-bottom: 20px;
  img{
    width:96px;
    height:96px;
    border-radius: 50%;
    cursor: pointer;
  }
}
.avatar-change{
  text-align: center;
  height:14px;
  font-size:14px;
  color:rgba(32,32,32,1);
  line-height:14px;
  margin-bottom: 20px;  
}
.avatar-text{
  text-align: center;
  font-size:12px;
  color:rgba(164,164,164,1);
  line-height:12px;
}
.big-photo-content{
  img{
    display: block;
    margin 0 auto;
    // width:860px;
    height:620px;
  }
}  
.sexClass{
  margin-bottom: 50px;
}
.curriculum{
  p{
    font-size: 14px;
    color:rgba(82,82,82,1);
    text-align: center;
  }
}
.curriculum-redact{
  font-size: 0;
  width: 776px;
  .curriculum-item{
    width: 164px;
    height: 164px;
    display: inline-block;
    margin-right: 30px;
    margin-bottom: 30px;
    vertical-align: top;
    position: relative;
    .icon-sanchutupian{
      position: absolute;
      z-index: 10;
      top: 10px;
      right: 10px;
      cursor: pointer;
      .path1,.path2{
        font-size: 22px; 
      }
      &:hover{
        .path2:before{
          color: rgb(255, 98, 82);
        }
      }
    }
    img{
      width: 100%;
      height: 100%;
    }
    .semester-select{
      height: 40px;
      position: absolute;
      bottom: 0;
      .el-select{
        width: 164px;
      }
    }
    .certificate-input{
      height: 40px;
      position: absolute;
      bottom: 0;
      .el-input{
        width: 164px;
      }
    }
  }
  >div:nth-child(4n){
    margin-right: 0;
  }
}
.curriculum-add{
  cursor:pointer;
  box-sizing: border-box;
  vertical-align: top;
  position: relative;
  width: 164px;
  height: 164px;
  display: inline-block;
  margin-right: 30px;
  margin-bottom: 30px;
  overflow: hidden;
  background:rgba(242,242,242,1);
  text-align: center;
  padding-top: 20px;
  .icon-tianjiatupian{
    font-size: 28px;  
  }
  input{
    position: absolute;
    top: 20px;
    height: 28px;
    width: 28px;
    cursor: pointer;
    opacity: 0;
    z-index: 1;
    left: 68px;
  }
  p{
    font-size:14px;
    text-align: center;
    color:rgba(118,118,118,1);
    line-height:14px;
    margin-bottom: 6px;
  }
  .curriculum-add-text{
    display: inline-block;
    font-size:12px;
    color:rgba(164,164,164,1);
    line-height:18px;
    padding: 0 24px;
  }
}  
.birthdayClass
  .birthday-year
    width: 150px;
    margin-right: 7px;
  .birthday-month
    width: 75px;
    margin-right: 7px;
  .birthday-day
    width: 75px;
.birthday-waring
  position: absolute;
  left: 340px;
  top: 50px;
  width: 450px;
  line-height: 14px;
  font-size: 12px;
  color: #FF0000;
.dialog-pic
  position: relative;
  
  padding:25px 20px 20px 20px;
  font-size:0;
  @media (min-width: 1920px)
    margin-bottom: 40px;
  >div
    vertical-align: top;
    font-size: 14px;
    display: inline-block;
  

.pic-confim
  text-align: center;
  padding: 20px 0;
  border-top: 1px solid #E5E5E5;
  @media (min-width: 1920px)
    padding: 39px 0;
  button
    width: 116px;
    height: 32px;
    font-size: 14px;
    border: 1px solid $color-theme;
    @media (min-width: 1920px)
      width: 144px;
      height: 44px;
      font-size: 18px;
  .pic-cencle
    color: $color-person-btn;
    background-color: #FFEFED;
    &:hover
      background: $color-theme;
      color: $color-text;
            
  .pic-seve
    margin-left: 30px;
    background: $color-theme;
    color: $color-text;
    &:hover
      background: $color-background-more;
      color: $color-text;
          


.pic-store
  width: 230px;
  font-size: 0;
  @media (min-width: 1920px)
    width: 384px;
    font-size:0;
  .avatar-photo:hover
    cursor: pointer;
  .avatar-photo
    vertical-align: top;
    display:inline-block !important;
    box-sizing:border-box;
    width:50px;
    height:50px;
    margin:0 39px 20px 0;
    border: 0
    @media (min-width: 1920px)
      width:66px;
      height:66px;
      margin:0 39px 32px 0;
  @media (max-width: 1919px)
    .avatar-photo:nth-child(3n)
      margin-right:0;
      margin-bottom: 12px !important;
  @media (min-width: 1920px)
    .avatar-photo:nth-child(4n)
      margin-right:0;
      margin-bottom: 12px !important;

.pagination
  position: absolute;
  bottom: 0;
  color: #A4A4A4;
  @media (min-width: 1920px)
    margin-top: 20px;

.pic-content
  width:220px;
  .content-avatar
    cursor:pointer;
    height:220px;
    .imgInput
      position: absolute;
      top: 25px;
      opacity: 0;
      width: 220px;
      height: 220px;
      font-size: 0;
      cursor: pointer;
    @media (min-width: 1920px)
      height:262px;
    img
      width:100%;
      height:100%;
  margin: 0 60px;
  @media (min-width: 1920px)
    width:262px;
    margin: 0 40px;

.preview
  img
    width:94px;
    height: 94px;
    border-radius: 50%;
  p
    text-align: center;
.my-upload:hover
  cursor: pointer;
.my-upload
  position: relative;
  .pic-select-text
    padding-top: 5px;
    text-align: left;
    color: $color-person-btn;

  .my-upload-input
    position: absolute;
    top: 2px;
    left: 0;
    z-index: 10;
    height: 30px;
    opacity: 0;
    cursor: pointer;
    .fileInput
      font-size: 0;
      cursor: pointer;
  input
    position: absolute;
    top: 0;
    left: 0;
    height: 30px;
    width: 200px;
    opacity: 0;
    cursor: pointer;



.no-data
  padding: 10px 0;
  margin: 0;
  text-align: center;
  color: #999;
  font-size: 14px;
.search-input
  margin-bottom 10px
  border-bottom 2px solid #eee
.secTitle {
  background:rgba(255,255,255,1);
  height:64px;
  position: relative;
  text-align: left;
  border-top-left-radius:4px;
  border-top-right-radius:4px;
  border-bottom: 1px solid rgba(238,238,238,1);
  span{
    display: inline-block;
  }

  .secTitle-text{
    font-size:16px;
    color:rgba(32,32,32,1);
    line-height:16px;
    padding-top: 24px;
    padding-left: 20px;
    cursor: pointer;
  }
  .redact-text{
    color:rgba(255,255,255,1);
    padding: 9px 30px;
    position: absolute;
    right: 20px;
    top: 16px;
    cursor: pointer;
    border-radius:2px;
    background: $color-person-btn;
  }
}

.formSection {
  padding-top: 60px;
  padding-bottom: 30px;
  margin-bottom: 30px;
  background:rgba(255,255,255,1);
  .picContent {
    @extend .clear-fix;
    margin-top: -32px;
    width: 320px;

    .avatar, .picture {
      position: relative;
      margin-bottom: 30px;

      .title {
        height: 14px;
        margin-bottom: 10px;
        line-height: 14px;
        text-index: 3px;
        color: $color-background;
        font-size: 14px;

        .star {
          color: #f56c6c;
          margin-right: 4px;
        }
      }

      .pic-text {
        position: absolute;
        left: 180px;
        top: 32px;
        width: 400px;
        font-size: $font-size-small;
      }

      .amend {
        position: absolute;
        left: 178px;
        top: 148px;
        color: $color-person-btn;
      }
    }


    .picture {
      float: left;
      width: 120px;
      margin-left: 80px;
    }

    .pictureNtice {
      overflow: hidden;
      position: absolute;
      width: 164px;
      height: 25px;
      color: #f56c6c;
      top: 194px;
      left: 0;

      .pictureText {
        position: absolute;
        top: -20px;
        left: 15px;
        font-size: $font-size-small;
        -webkit-transition: all 0.2s;
        -ms-transition: all 0.2s;
        -o-transition: all 0.2s;
        -moz-transition: all 0.2s;
        transition: all 0.2s;
      }
    }

    img.my-avatar {
      display: block;
      width: 164px;
      height: 164px;
    }

    p {
      @extend .clear-default;
      font-size: $font-size-small-s;
      color: $color-text-ll;
      line-height: 20px;
    }
  }

  .middle {
    position: relative;

    .picture {
      width: 600px;
      margin-left: 0;
    }

    .middleBtn {
      top: 32px;
    }

    .button {
      left: 0;
    }
  }

  .nickNotice {
    overflow: hidden;
    position: absolute;
    height: 20px;
    width: 200px;
    line-height: 20px;
    padding: 0;
    color: #f56c6c;
    font-size: 10px;

    span {
      position: absolute;
      top: -20px;
      -webkit-transition: all 0.2s;
      -moz-transition: all 0.2s;
      -ms-transition: all 0.2s;
      -o-transition: all 0.2s;
      transition: all 0.2s;
    }

    .on {
      top: 0;
    }

    .off {
      top: -20px;
    }
  }

  .sexNotice {
    overflow: hidden;
    position: absolute;
    width: 100px;
    height: 16px;
    margin: 0;
    padding: 0;
    line-height: 12px;
    color: #f56c6c;
    font-size: 12px;

    .noticeText {
      -webkit-transition: all 0.2s;
      -ms-transition: all 0.2s;
      -o-transition: all 0.2s;
      -moz-transition: all 0.2s;
      transition: all 0.2s;
      position: absolute;
      top: -15px;
    }
  }

  .uploadBtn {
    @extend .clear-fix;
    position: absolute;
    top: -7px;
    left: 0;
    width: 164px;
    height: 164px;

    label {
      position: absolute;
      width: 164px;
      height: 164px;
      cursor: pointer;
      z-index: 10;

      input {
        position: absolute;
        top: 0;
        left: 0;
        width: 164px;
        height: 164px;
        opacity: 0;
      }
    }

    .button {
      width: 164px;
      height: 164px;
      outline: none;
      cursor: pointer;
    }
  }

  .fixedPhone {
    margin: 0;
  }

  .notice {
    position: absolute;
    left: 340px;
    top: 14px;
    width: 450px;
    line-height: 14px;
    font-size: $font-size-small;
    color: $color-text-ll;
  }
  .emailCheck-wrapper{
    margin-bottom: 30px;
    .emailCheck{
      display: inline-block;
      height: 38px;
      width: 87px;
      margin-left: 6px;
      line-height: 38px;
      text-align: center;
      background-color: rgba(48,192,96,1);
      border-radius: 2px;
      color: #fff;
      font-size: $font-size-medium;
      &:hover{
        text-decoration: none;
      }
    }
    .emailCheck.on{
      background-color: rgba(255,98,82,1);
    }
    .authenticated{
      margin-left: 5px;
      color: $color-text-ll;
      font-size: $font-size-medium;
    }

    .revamp{
      color: $color-text-mt;
      font-size: $font-size-medium;
      text-decoration: underline;
    }
    .red{
      color: $color-pay-text;
    }
    .emailNotice{
      left: 340px;
    }
  }


}

.avatarNotice {
  overflow: hidden;
  position: absolute;
  text-align: right;
  top: 6px;
  right: 0;
  width: 164px;
  height: 25px;
  color: #f56c6c;

  .avatarText {
    position: absolute;
    top: -20px;
    right: 0;
    font-size: $font-size-small;
    -webkit-transition: all 0.2s;
    -ms-transition: all 0.2s;
    -o-transition: all 0.2s;
    -moz-transition: all 0.2s;
    transition: all 0.2s;
  }
}
.formSection :last-child{
  margin-bottom: 0;
}
.saveBtn {
  padding-left: 100px;
  height: 55px;
  margin-bottom: 30px;
  button {
    color: $color-text;
    width: 144px;
    height: 44px;
    border: 1px solid $color-theme;
    border-radius: 4px;
    margin-top: 10px;
    background-color: $color-person-btn;
    transition: all 0.3s;

    &:hover {
      background-color: #f73c28;
      color: $color-text;
      border: 1px solid #f73c28;
      opacity: 1;
    }
  }
}

.orderBody {
  .orderContent {
    padding-bottom: 30px;
    border-bottom: 1px dashed #cdcdcd;

    .order {
      @extend .clear-fix;

      >div {
        float: left;
        width: 16%;
        text-align: center;
        line-height: 200px;

        p {
          @extend .clear-default;
        }
      }

      >div+div {
        margin-left: 8px;
      }

      .orderName {
        color: $color-text-m;
        font-size: $font-size-large;
      }

      .orderCourse {
        position: relative;
        height: 200px;
        text-align: center;
        line-height: 20px;
        color: $color-text-l;
        font-size: $font-size-medium;

        .listWrapper {
          position: absolute;
          top: 50%;
          -moz-transform: translateY(-50%);
          -o-transform: translateY(-50%);
          -ms-transform: translateY(-50%);
          -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
        }

        .dachedLine {
          display: block;
          margin: 0 auto;
          margin-top: 10px;
          height: 0;
          width: 16%;
          border: 1px dashed #CDCDCD;
        }

        p {
          display: inline-block;
          padding-top: 10px;
          vertical-align: middle;
          line-height: 20px;
        }
      }

      .orderPrice {
        color: $color-text-m;
        font-size: $font-size-large;
      }

      .orderPay {
        color: $color-sub-pay;
      }

      .orderStatus {
        color: $color-text-m;
        font-size: $font-size-large;
      }

      .orderStatus span.red {
        color: #537AAA;
      }

      .orderStatus span.blue {
        color: #52C41A;
      }

      .orderStatus span.green {
        color: #D42222;
      }

      .orderOperate {
        line-height: 20px;

        .operateBtn {
          line-height: 20px;
          margin-top: 85px;

          button {
            width: 88px;
            height: 32px;
          }

          .main {
            display: inline-block;
            width: 88px;
            height: 32px;
            background-color: $color-text;
            border: 1px solid $color-sub-pay;
            line-height: 32px;
            border-radius: 4px;
            text-decoration: none;
            color: $color-sub-pay;
            cursor: pointer;
            outline: none;
          }

          .sub {
            display: block;
            margin: 10px auto;
            color: $color-text-ll;
            font-size: $font-size-medium;
            cursor: pointer;

            &:hover {
              text-decoration: underline;
            }
          }
        }
      }
    }

    .bottomInfo {
      padding-right: 54px;
      text-align: right;
      font-size: $font-size-medium;
      color: $color-text-l;

      .orderCode {
        margin-left: 32px;
      }
    }
  }
}

.el-form-item__label {
  color: $color-text-ll;
  font-size: $font-size-medium-x;
  padding: 0 26px 0 0;
}

.el-input, .el-select {
  width: 320px;
}

.el-input__inner {
  border: 1px solid #CDCDCD;
}
.sex-notice{
  left: 145px !important;  
}
.phone-notice{
  left: 143px !important;
}

</style>

<script>
// import VueCropper from 'vue-cropper'
import { mapGetters, mapActions } from 'vuex'
import VueUploadComponent from 'vue-upload-component'
import calendar from 'api/calendar';
import moment from 'moment'
import {
  fileUpload,
  userInfo,
  updateInfo,
  checkNickName,
  checkInfoSave,
  checkEmail,
  emailSend,
  getMinusTime,
  uploadBase64,
  courseDetail
} from "api/getData";
export default {
  components: {
    FileUpload: VueUploadComponent
  },
  created() {
    this.formLoading = this.getLoading()
    // console.log("needSupplyInfo:",this.needSupplyInfo)
  },
  mounted() {
    let that = this;
    window.onresize = () => {
      return (() => {
        window.screenWidth = window.innerWidth
        if(1920 <= window.screenWidth){
          that.pageSize = 12
          that.creatrCurrentPhotoList()
        }else {
          that.pageSize = 9
          that.creatrCurrentPhotoList()
        }
        
      })()
    }
    this.getYearList();
    this.getMonthList();
    this.getDayList();
    if(1920 <= this.screenWidth){
      this.pageSize = 12
      this.creatrCurrentPhotoList()
    }else {
      this.pageSize = 9
      this.creatrCurrentPhotoList()
    }
    let len = this.photoList.length;
    this.totlaPage = Math.floor(len/this.pageSize)
    
    // 获取用户信息
    this.getUserInfo()
    // 判断性别
    if (!this.sex) {
      this.$refs.noticeText.style.top = '-15px'
    }
  },
  data() {
    let validateYear = (rule, value, callback) => {
        if (this.year == '') {
          callback(new Error('请输入年'));
        } else {
          callback();
        }
      };
    let validateMonth = (rule, value, callback) => {
      if (this.month == '') {
        callback(new Error('请输入月'));
      } else {
        callback();
      }
    };
    let validateDay = (rule, value, callback) => {
      if (this.day == '') {
        callback(new Error('请输入日'));
      } else {
        callback();
      }
    };
    return {
      formData: {
        projectCycle: '',
        nickname: "",
        sex: "",
        name: "",
        email: "",
        phone: "",
        idCard: "",
        QQ: "",
        school: "",
        grade: "",
        major: "",
        college: "",
        avatar: "https://gok-file.obs.cn-south-1.myhwclouds.com/default.png",
        picture: "",
        education: "",
        city: "",
        birthday: "",
        birthType: "",
        identity: "2",
        curriculumList: [],
        certificateList: []
      },
      basicRules: {
        year: [
          {
            validator: validateYear,
            trigger: "change"
          }
        ],
        month: [
          {
            validator: validateMonth,
            trigger: "change"
          }
        ],
        day: [
          {
            validator: validateDay,
            trigger: "change"
          }
        ],
        nickname: [
          {
            required: true,
            message: "昵称不能为空",
            trigger: "blur",
          },
          { min: 2, max: 12, message: '昵称设置需满足2-12个中英文字符', trigger: 'blur' }
        ],
        sex: [
          {
            required: false,
            message: "请选择性别",
            trigger: "change"
          }
        ]
      },
      contactRules: {
        name: [
          {
            required: true,
            message: "请输入名字",
            trigger: "blur"
          },
          {
            pattern: /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/,
            message: "请输入中文全名2-12个字",
            trigger: "blur"
          }
        ],
        idCard: [
          {
            required: true,
            message: "请输入身份证号码",
            trigger: "blur"
          },
          {
            pattern: /^[1-9]\d{5}(19\d{2}|20[01][0-8])(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])\d{3}[\dxX]$/,
            message: "输入的身份证必需15-18字符,请保持格式正确",
            trigger: "blur"
          }
        ],
        QQ: [
          {
            required: true,
            message: "请输入您的QQ",
            trigger: "blur"
          },
          {
            pattern: /^[1-9]\d{4,18}$/,
            message: "您输入的QQ有误",
            trigger: "blur"
          }
        ]
      },
      schoolRules: {
        // 城市
        city: [
          {
            required: true,
            message: "请选择城市",
            trigger: "change"
          },
          {
            message: "请选择城市"
          }
        ],
        // 学校
        school: [
          {
            required: true,
            message: "请选择学校",
            trigger: "change"
          },
          {
            message: "请选择学校"
          }
        ],
         // 学院
        college: [
          {
            required: true,
            message: "请选择学院",
            trigger: "change"
          },
          {
            message: "请选择学院"
          }
        ],
        // 年级
        grade: [
          {
            required: true,
            message: "请选择入学年份",
            trigger: "change"
          }
        ],
        // 专业
        major: [
          {
            required: true,
            message: "请正确输入您的专业",
            trigger: "change"
          },
          {
            message: "请正确输入您的专业"
          }
        ],
        // 学历
        education: [
          {
            required: true,
            message: "请选择学历",
            trigger: "change"
          },
        ]
      },
      myIdCard: '',
      myphone: '',
      bigPhoto: false,
      bigPhotoSrc: '',
      certificateLoading: false,
      curriculumLoading: false,
      semesterList: [],
      screenWidth: window.innerWidth,
      loading: '',
      formLoading: '',
      avatarIsHttp: false,
      example: {
        autoCrop: true,
        canScale: false,
        centerBox: true,
        canMove: false,
        autoCropWidth: 160,
        autoCropHeight: 160,
        fixed: true
      },
      jiazi: [
        '甲子','乙丑','丙寅','丁卯','戊辰','已巳','庚午','辛未','壬申','癸酉','甲戌','乙亥','丙子','丁丑','戊寅','已卯','庚辰','辛巳','壬午','癸未',
        '甲申','乙酉','丙戌','丁亥','戊子','已丑','庚寅','辛卯','壬辰','癸巳','甲午','乙未','丙申','丁酉','戊戌','已亥','庚子','辛丑','壬寅','癸卯',
        '甲辰','乙巳','丙午','丁未','戊申','已酉','庚戌','辛亥','壬子','癸丑','甲寅','乙卯','丙辰','丁巳','戊午','已未','庚申','辛酉','壬戌','癸亥'
      ],
      gMonthList: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
      nMonthList: ['正月','二月','三月','四月','五月','六月','七月','八月','九月','十月','冬月','腊月'],
      nDayList: ['初一', '初二', '初三', '初四', '初五', '初六', '初七', '初八', '初九', '初十', '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十', '廿一', '廿二', '廿三', '廿四', '廿五', '廿六', '廿七', '廿八', '廿九', '三十'],
      birType: '0',
      birthFlow: false,
      year: '',
      month: '',
      day: '',
      yearList:[],
      monthList: [],
      dayList:[],
      //头像及头像分页
      previewUrl: '',
      temporaryUrl: '',
      photoList: [
        '/images/avatar/1.png',
        '/images/avatar/2.png',
        '/images/avatar/3.png',
        '/images/avatar/4.png',
        '/images/avatar/5.png',
        '/images/avatar/6.png',
        '/images/avatar/7.png',
        '/images/avatar/8.png',
        '/images/avatar/9.png',
        '/images/avatar/10.png',
        '/images/avatar/11.png',
        '/images/avatar/12.png',
        '/images/avatar/13.png',
        '/images/avatar/14.png',
        '/images/avatar/15.png',
        '/images/avatar/16.png',
        '/images/avatar/17.png',
        '/images/avatar/18.png',
        '/images/avatar/19.png',
        '/images/avatar/20.png',
        '/images/avatar/21.png',
        '/images/avatar/22.png',
        '/images/avatar/23.png',
        '/images/avatar/24.png',
        '/images/avatar/25.png',
        '/images/avatar/26.png',
        '/images/avatar/27.png',
        '/images/avatar/28.png'
      ],
      pageSize: 9,
      currentPhotoPage: 0,
      totlaPage: 0,
      currentPhotoList: [],
      picVisible: false,
      noData:false,
      searchKey:'',
      filesAva: [],
      filesPic: [],
      schoolList: {},
      // 个人资料
      sex: "",
      nameDisabled: false,
      idCardDisabled: false,
      gradeArr: [],
      educationArr: {},
      education: '',
      collegeList: [],
      majorList: [],
      sexBool: false,
      sexCheckBool: false,
      nearlyBirthday:'',
      // 昵称矫验数据
      nickData: {
        text: "",
        bool: true
      },
      // 昵称初始名字
      sNickname: "",
      // 头像验证
      avaNotice: {
        text: '请提交头像！',
        bool: false
      },
      picNotice: {
        text: '请提交图片！',
        bool: false
      },
      pictureBool: false,
      saveData: '保存',
      
      emailCheck: {
        emailNotice: '用于接收来自平台和课程的邮件通知，修改密码，非常重要',
        className: '',
        timer: null,
        canClick: false,
        canUse: false
      }
    };
  },
  computed: {
    ...mapGetters(["currentUser", "needSupplyInfo", "cityId", "cityList","cityListAll", "cityName","showEmailBtnBool"]),
    nameDisabledFn() {
      return this.nameDisabled
    },
    idCardDisabledFn() {
      return this.idCardDisabled
    }

  },
  methods: {
    removeCertificate(index){
      this.$confirm('是否删除证书?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
      }).then(res=>{
        this.formData.certificateList.splice(index, 1)
        this.$forceUpdate()
      }).catch(() => {
      })
    },
    removeSemester(index){
      this.$confirm('是否删除课表?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
      }).then(res=>{
        this.formData.curriculumList.splice(index, 1)
        this.$forceUpdate()
      }).catch(() => {      
      })
    },
    //查看大图
    bigPhotoLog(photo){
      this.bigPhotoSrc = photo;
      this.bigPhoto = true;
    },
    changeSemester(e, key){
      let that = this;
      let flow = 0;
      // console.log(e,key)
      for(let i=0;i<this.formData.curriculumList.length;i++){
        if(this.formData.curriculumList[i].semester==e){ 
          flow+=1;
        }
      }
      if(flow>2){     
        this.$message({
          message: '相同学期课表不能超过2张！',
          type: 'warning'
        })
        this.formData.curriculumList[key].semester = '';
        this.formData.curriculumList[key].orders='';
        this.$forceUpdate()
        return
      }else{
        let order = 1 + Number(e)
        this.formData.curriculumList[key].semester = e;
        this.formData.curriculumList[key].orders=order;
        this.$forceUpdate()
      }
         
    },
    
    addCurriculum(prame,e){
      let that = this;
      let value = e || window.event;
      let target = value.srcElement || value.target;
      let picData = target.files[0];
      if (picData.size / 1024 > 2000) {
        this.$message({
            message: '图片太大了！',
            type: 'warning',
            duration: 1500
        })
        target.value = '';
        return
      }
      if(!this.getFileType(picData)){
        this.$message({
            message: '文件格式不支持！',
            type: 'warning',
            duration: 1500
        })
        return
      }
      //清空图片
      if(target.files.length!=0){
        target.value = '';
      }
      let param = new FormData(); //创建form对象
      param.append("file", picData); //通过append向form对象添加数据
      let config = {
        headers: {
          "Content-Type": "multipart/form-data"
        }
      }; //添加请求头
      if(prame == 'curriculum'){
        that.curriculumLoading = true;
        fileUpload(param, config).then(response => {
          that.formData.curriculumList.push({
            'picture': response.url,
            'semester': ''
          })
          that.curriculumLoading = false;
        })
      }
      if(prame == 'certificate'){
        if(that.formData.certificateList.length>3){
          this.$message({
            message: '证书最多不能超过4张！',
            type: 'warning'
          })
          return
        }
        that.certificateLoading = true,
        fileUpload(param, config).then(response => {
          // console.log(response)
          that.formData.certificateList.push({
            'url': response.url,
            'type': '',
            'id': ''
          })
          that.certificateLoading = false
        })
      }
    },
    
    //头像拖动截图
    // creatImg(e){
    //   if(!e.moving){
    //     this.$refs.cropper.goAutoCrop;
    //     this.$refs.cropper.getCropData((data) => {
    //       this.previewUrl = data
    //     })
    //   }
    // },
    changeBirthType(){
      this.year = '';
      this.month = '';
      this.day = '';
      this.getYearList()
      this.getMonthList()
      this.getDayList()
    },
    changeYear(e){
      this.month = '';
      this.day = '';
      this.getMonthList();
      this.getDayList();
    },
    changeMonth(e){
      this.day = '';
      this.getDayList();
      this.birFlowWr('m')
    },
    //生日超出
    async birFlowWr(mord){
      let dTime=0,sTime=0;
      if(this.birType == '0'){
        if(this.year == ''){
          return;
        }
        let y = this.year.replace(/[^\d]/g,'')
        let m = this.month.replace(/[^\d]/g,'')
        let d = '1';
        if(mord == 'd'){
          d = this.day.replace(/[^\d]/g,'')
        }
        let ymd = y + '/' + m + '/' + d;
        dTime = new Date(ymd).valueOf()
      }else{
        if(this.year == ''){
          return;
        }
        let m = 0, d = 1;
        let y = this.year.replace(/[^\d]/g,'')
        let tmonth = new RegExp('闰')
        let res = tmonth.test(this.month)
        for(let i=0;i<this.monthList.length;i++){
          if(this.month == this.monthList[i]){
            if(res){
              m = i;
              break;
            }
            m = i+1;
            break;
          }
        }
        if(mord == 'd'){
          for(let i=0;i<this.dayList.length;i++){
            if(this.day == this.dayList[i]){
              d = i + 1;
              break;
            }
          }
        }

        let cBirthday = '';
        if(res){
          cBirthday = calendar.lunar2solar(y,m,d,true)
        }else{
          cBirthday = calendar.lunar2solar(y,m,d,false)
        }
        let ymd = cBirthday.cYear + '/' + cBirthday.cMonth+ '/' + cBirthday.cDay;
        dTime = new Date(ymd).valueOf()
      }
      await getMinusTime().then(res => {
          if(res.code == 0){
            sTime = res.data.currentTime
          }
        })
      if(dTime>sTime){
        this.birthFlow = true;
      }else{
        this.birthFlow = false;
      }
    },
    changeDay(e){
      this.birFlowWr('d')
    },
    getYearList(){
      let yearNow = new Date().getFullYear();
      let yearIndex = 36;
      if(this.birType == '0'){
        this.yearList = [];
        for (let i=yearNow;i>1900;i--)
        {
          this.yearList.push(i + '年')
        }
      }else {
        //农历
        this.yearList = [];
        for (let i=1900;i<yearNow+1;i++)
        {
          let v = this.jiazi[yearIndex] + i;
          if(yearIndex<59){
            yearIndex++;
          }else {
            yearIndex=0;
          }
          this.yearList.push(v)
        }
        this.yearList = this.yearList.reverse();
      }
      //console.log(this.yearList)
    },
    getMonthList(){
      this.monthList = [];
      if(this.birType == '0'){
        this.monthList = this.gMonthList
      }else {
        let run = 0;
        if(this.year == ''){
          run = calendar.leapMonth(new Date().getFullYear())
        }else{
          run = calendar.leapMonth(this.year.replace(/[^\d]/g,''))
        }
        this.monthList = this.nMonthList.slice(0)
        if(run != 0){
            let rtxt = '闰' + (this.monthList[run-1]);
            this.monthList.splice(run, 0, rtxt)
        }
      }
    },
    getDayList(){
      this.dayList = [];
      if(this.birType == '0'){
        let d = this.mGetDate(this.year,this.month);
        for (let i=1;i<d+1;i++)
        {
          this.dayList.push(i + '日')
        }
      }else {
        let tmonth = new RegExp('闰')
        let res = tmonth.test(this.month)
        for(let i=0;i<this.monthList.length;i++){
          if(this.month == this.monthList[i]){
            let y = this.year.replace(/[^\d]/g,'');
            let d =0;
            if(res){
              d = calendar.leapDays(y, i+1)
            }else{
              d = calendar.monthDays(y, i+1)
            }
            if(d == 29){
              this.dayList = this.nDayList.slice(0, -1)
            }else {
              this.dayList = this.nDayList
            }
            //console.log(this.dayList)
            return
          }
        }
      }
    },
    //获取公历日
    mGetDate(year, month){
      if(year){
        year = year.replace('年', '');
      }else {
        year = new Date().getFullYear();
      }
      if(month){
        month = month.replace('月', '');
      }else {
        month = 1;
      }
      let d = new Date(Number(year), Number(month), 0);
      return d.getDate();
    },
    //确认保存头像
    confimPhoto(){
      this.formData.avatar = this.temporaryUrl
      this.picVisible = false
    },
    toggleAvatar(url){
      this.temporaryUrl = 'static' + url;
      this.previewUrl = this.temporaryUrl;
      this.avatarIsHttp = false;
    },
    showPhotoLog(){
      if(this.basicDisable){
        return
      }
      this.picVisible = true
    },
    cenclePhotoLog(){
      this.picVisible = false
    },
    togglePhotoList(a){
      if(a==0 && this.currentPhotoPage>0){
        this.currentPhotoPage--;
        this.creatrCurrentPhotoList();
      }
      if(a==1 && this.currentPhotoPage < this.totlaPage){
        this.currentPhotoPage++;
        this.creatrCurrentPhotoList();
      }
    },
    creatrCurrentPhotoList(){
      let len = this.photoList.length;
      let pageStart = this.currentPhotoPage*this.pageSize;
      if((len - pageStart) > this.pageSize){
        this.currentPhotoList = this.photoList.slice(pageStart,pageStart+this.pageSize)
      }else {
        this.currentPhotoList = this.photoList.slice(pageStart)
      }
    },
    changeSchoolList(city, e) {
      let that = this;
      // console.log(city)
      if(e==-1)
      {
        that.schoolList = [
          
        ]
        return
      } 
      city.forEach(item => {
        if(item.id == e){
          that.schoolList = item.localAreas
        }
      })
    },
    te(list,name){
      this.searchKey = ''
      this.noData =false
      for ( let i=0; i<this[list].length;i++){
          this[list][i].filterResult = false
      }
    },

    // 邮箱输入时验证
    emailInp(e){
      if(e.keyCode == 8 || e.keyCode == 46 ){
        this.setShowEmailBtn(true)
      }
      this.$set(this.emailCheck, 'canUse', false)
      this.checkFn()
    },
    // 点击修改邮箱
    revampEmail(){
      this.setShowEmailBtn(true)
      this.$set(this.formData, 'email', '')
      this.$refs.emailDom.focus()
    },
    checkFn(){
      let _this = this,
        email = this.formData.email
      clearTimeout(this.emailCheck.timer)

      this.$set(this.emailCheck, 'timer', setTimeout(() => {
        let reg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/

        this.$refs.emailDom.$el.children[0].style.border = '1px solid #f56c6c'
        if(reg.test(email)){
          checkEmail(email, this.currentUser.cluesOrStuId).then(res =>{
            if(res.status == 0 ){ // 邮箱未激活
              _this.$set(_this.emailCheck, 'className', 'red')
              _this.$set(_this.emailCheck, 'emailNotice', '该邮箱可以使用，请前往验证！')
              _this.$set(_this.emailCheck, 'canClick', true)
              _this.$set(_this.emailCheck, 'canUse', true)

            } else if(res.status == 1){ // 邮箱可以正常使用

              _this.$set(_this.emailCheck, 'emailNotice', '用于接收来自平台和课程的邮件通知，修改密码，非常重要')
              _this.$set(_this.emailCheck, 'className', '')
              _this.$set(_this.emailCheck, 'canUse', true)  
              _this.setShowEmailBtn(false)
              _this.$refs.emailDom.$el.children[0].style.border = '1px solid #dcdfe6'

            } else if(res.status == 2){ // 邮箱已经被其他人使用
              _this.$set(_this.emailCheck, 'emailNotice', '邮箱已经被其他人使用，请更换邮箱')
              _this.$set(_this.emailCheck, 'className', 'red')
              _this.$set(_this.emailCheck, 'canUse', true)
            }
          })

        } else {
          this.$set(this.emailCheck, 'emailNotice', '邮箱格式错误')
          this.$set(this.emailCheck, 'canClick', false)
          this.$set(this.emailCheck, 'className', 'red')
        }
      }, 500))
    },
    // 邮箱失去焦点的时候
    emailBlur(){
      if(this.emailCheck.canUse) return
      if(!this.formData.email){
        this.$set(this.emailCheck, 'emailNotice', '请输入新邮箱')
        return
      }
      this.checkFn()
    },
    focusInp(){
      this.setShowEmailBtn(true)
      this.$set(this.emailCheck, 'canClick', false)
      this.$set(this.emailCheck, 'className', 'red')
      this.$set(this.emailCheck, 'emailNotice', '请输入新邮箱')
      this.$set(this.emailCheck, 'canUse', false)
      this.$refs.emailDom.$el.children[0].style.border = '1px solid #f56c6c'
    },

    // 点击邮箱跳转页面
    goCheckPage(){
      if(!this.emailCheck.canClick) return 

      let email = this.formData.email,
      _this = this

      let tempwindow = window.open('about:blank')

      emailSend(email).then(res =>{
        let routeData = _this.$router.resolve({
                  path: "/emailCheckPage",
                  query: {
                    emailName: email,
                    index: '2'
                  },
                });
          let url = 'https://' + window.location.host + routeData.href;
          tempwindow.location.href = url;
          this.isCheck()
      })

    },
    isCheck(){
      let _this = this
      checkEmail(this.formData.email, _this.currentUser.cluesOrStuId).then(res =>{
        if(res.status == 1){ // 邮箱可以正常使用
            _this.$set(_this.emailCheck, 'emailNotice', '用于接收来自平台和课程的邮件通知，修改密码，非常重要')
            _this.$set(_this.emailCheck, 'className', '')
            _this.setShowEmailBtn(false)
            _this.$refs.emailDom.$el.children[0].style.border = '1px solid #dcdfe6'
        } else {
          setTimeout(()=>{
            _this.isCheck()
          }, 3000)
        }
      })
    },

    setFilter(list,name){
      if(this.searchKey == ''){
        this.noData = false
      }
      let reg = new RegExp(this.searchKey);
      let arr = []
      for ( let i=0; i<this[list].length;i++){
        if(!reg.test(this[list][i][name])){
          this[list][i].filterResult = true
          arr.push(i)
        }else {
          this[list][i].filterResult = false
        }
      }
      if(arr.length == this[list].length){
        this.noData = true
      }

    },
    changeCollegeList(school, e) {
      let that = this;
      
      if(e == ''){
        e = school[0].id
      }
      if(e == '-1'){
        that.collegeList = []
        return
      }
      school.forEach(item => {
        if(item.id == e){
          that.collegeList = item.institutes
        }
      })
        
    },
    changeMajorList(college, e) {
      let that = this;
      if(e == ''){
        e =college[0].id
      }
      if(e == '-1'){
        that.majorList = []
        return
      }
      college.forEach(item => {
        if(item.id == e){
          that.majorList = item.majors
        }
      })
    },
    //选择城市
    async changeCity(e) {
      this.formData.school = '';
      this.formData.college = '';
      this.formData.major = '';
      await this.changeSchoolList(this.cityListAll, e)
      this.collegeList = []
      this.majorList = []
    },
    //选择学校
    async changeSchool(e) {
      this.formData.college = '';
      this.formData.major = '';
      await this.changeCollegeList(this.schoolList, e)
      this.majorList = []
    },
    //选择学院
    changeCollege(e) {
      this.formData.major = '';
      this.changeMajorList(this.collegeList, e)
    },
    changeMajor(e) {
      //console.log(e,this.formData)
    },
    //清空头像
    clearFile(e){
      let value = e || window.event;
      let target = value.srcElement || value.target;
      if(target.files.length!=0){
        target.value = '';
      }
    },

    getFileType(fileObj){
      let fileType = (fileObj.name.substr(fileObj.name.lastIndexOf("."))).toLowerCase()
      switch (fileType){
        case '.jpg' : return true
        case '.jpeg' : return true
        case '.png' : return true
        case '.gif' : return true
        case '.bmp' : return true
        default: return false
      }
       
    },
    async pickAva(e) { // 头像上传
      let value = e || window.event;
      let target = value.srcElement || value.target;
      let picData = target.files[0];
      if (picData && picData.size / 1024 < 2000) {
        let fileBool = this.getFileType(picData)
        if(fileBool){
          this.loading = this.getLoading(' ')
          this.filesAva = picData;
          this.uploadAva(picData,'头像上传中...')
        }else{
          this.uploadFileHint(this.avaNotice,this.$refs.avatarText,'文件格式不支持')
        }
        
      }else{
        this.uploadFileHint(this.avaNotice,this.$refs.avatarText,'头像太大了，换一张试试')
      }
    
    },
    uploadFileHint(text,node,newText){
      let that = this;
      node.style.top = '5px'
      that.$set(text, 'text', newText)
      setTimeout(() => {
          node.style.top = '-20px'
      }, 1000)
    },
    pickPic(e) { // 照片上传
      let that = this;
      let value = e || window.event;
      let target = value.srcElement || value.target;
      let picData = target.files[0]; 
      if(picData && picData.size / 1024 > 2000){
        that.uploadFileHint(this.picNotice,this.$refs.pictureText,'照片太大了，换一张试试')
        return
      } 
      if(picData && picData.size / 1024 < 2000){
        let fileBool = this.getFileType(picData)
        if(fileBool){
          this.uploadPic(picData);
        }else{
          that.uploadFileHint(this.picNotice,this.$refs.pictureText,'文件格式不支持')
        }
      }
    },
    limit(attr, num) {
      if(!this.formData[attr]){
        return;
      }
      if(attr == 'QQ'){
        this.formData[attr] = this.formData[attr].replace(/[^\d]/g, '')
      }
        if(attr == 'idCard'){
         this.formData[attr] = this.formData[attr].replace(/[^\d+(x|X)?]/g, '')
      }
      if (this.formData[attr] && this.formData[attr].length >= num) {
        this.formData[attr] = this.formData[attr].slice(0, num)
      }
    },
    getUserInfo() {
      let that = this;
      userInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), that.cityId).then(data => {
        
        that.formData = data.info;
        /******基本信息*******/
        // 头像avatar
        // console.log(that.formData)
        if (!data.info.avatar) {
          this.$set(that.formData, "avatar", 'https://gok-img.oss-cn-beijing.aliyuncs.com/1536658193474.png?Expires=1852018193&OSSAccessKeyId=LTAIMqiysbMNDxZD&Signature=15itbq99U%2FkqC11LJXqWn79LSbc%3D')
        }
        let patt1 = new RegExp("http");
        let resultA = patt1.test(data.info.avatar);
        if(resultA){
          this.avatarIsHttp = true;
        }else{
          this.avatarIsHttp = false;
          this.$set(that.formData, "avatar", 'static'+data.info.avatar)
        }
        this.temporaryUrl = this.formData.avatar;
        this.previewUrl = this.temporaryUrl;
        
        // 处理生日
        let bir = data.info.birthday.split('/');
        if(!data.info.birthType || data.info.birthType == 0){
          //console.log('birtepe:',data.info.birthType)
          that.birType = '0';
          if(bir.length >2){
            that.year = bir[0] + '年';
            that.month = Number(bir[1]) + '月';
            that.day = Number(bir[2]) + '日';
          }
        }else{
          that.birType = '1';
          if(bir.length > 2){
            let b = calendar.solar2lunar(bir[0],bir[1],bir[2]);
            that.year = b.gzYear + bir[0];
            that.month = b.IMonthCn;
            that.day = b.IDayCn;
          }
        }
        this.getYearList()
        this.getMonthList()
        this.getDayList()
        // 格式化性别
         if (data.info.sex) {
          this.sexCheckBool = true
        }     
        // 昵称初始值
        this.sNickname = data.info.name;
        //证书
        if(data.certificateList){
          this.formData.certificateList = data.certificateList;
        }else{
          this.formData.certificateList = [];
        }
        
        /******联系信息*******/
        if (data.info.name) {
          this.nameDisabled = true
        }
        // 判断邮箱有没有数据
        if(data.info.email){
          this.setShowEmailBtn(false)
        } else {
          this.setShowEmailBtn(true)
          this.$set(this.emailCheck, 'canClick', false)
          this.$set(this.emailCheck, 'className', 'red')
          this.$set(this.emailCheck, 'emailNotice', '请输入邮箱地址')
        }
        //console.log('that.majorList:',that.majorList)
        // 照片
        if (!data.info.picture && this.currentUser.type==1) {
          this.$set(that.formData, "picture", 'static/add.png')
        }
        if (!data.info.picture && this.needSupplyInfo==2) {
          this.$set(that.formData, "picture", 'static/add.png')
        }
        //身份证   
        if(data.info.idCard){
          let idCard3 = data.info.idCard.slice(0,4).toString()
          let idCard4 = data.info.idCard.slice(data.info.idCard.length - 4).toString()
          this.myIdCard = idCard3 +'****'+ idCard4
        }
        // 手机
        if(data.info.phone){
          let phone3 = data.info.phone.slice(0,3).toString()
          let phone4 = data.info.phone.slice(7).toString()
          this.myphone =  phone3 +'****'+ phone4
        }
        /*****学校信息*******/
        // 处理年级
        let gradeArr = data.grade,
          length = gradeArr.length
        for (var i = 0; i < length; i++) {
          this.gradeArr.push(gradeArr[i].value)
        }
        // 处理学历
        
        that.educationArr = data.educationList
        //  添加学校列表
        // console.log(this.cityListAll)
        if(!data.info.city){
          //添加城市
          this.formData.city = that.cityId.toString();
        }else{
          this.formData.city = data.info.city.toString();
        }
        that.cityListAll.forEach(item =>{
          if(item.id ==  that.formData.city){
            that.schoolList = item.localAreas
          }
        })

        // console.log('that.schoolList:',that.schoolList)
        // 学院
        if(that.schoolList.length != 0 && that.formData.school != '' && that.schoolList.length != null) {
          that.schoolList.forEach(item => {
            if(item.id == that.formData.school){
              that.collegeList = item.institutes
            }
          })
        }else {
          that.collegeList = [];
          that.majorList = [];
        }
        // //专业
        if(that.collegeList.length != 0 && that.formData.college != '' && that.collegeList.length != null) {
          let hasCollege = false;
          that.collegeList.forEach(item => {
            if(item.id == that.formData.college){
              that.majorList = item.majors;
              hasCollege = true;
            }
          })
        }else {
          that.majorList = [];
        }
        if(that.majorList.length != 0 && that.formData.major != ''  && that.majorList.length != null) {
          let hasMajor = false;
          that.majorList.forEach(item => {
            if(item.id == that.formData.major){
              hasMajor = true;
            }
          })
        }
        // 课表
        this.formData.curriculumList=[]; 
        this.semesterList = data.semesterList
        if(data.schoolTimetableList){
          data.schoolTimetableList.forEach(item => {
            if(item.pictureOne){
              this.formData.curriculumList.push({
                'picture': item.pictureOne,
                'semester': item.semesterId.toString(),
                'orders': item.orders
              })
            }
            if(item.pictureTwo){
              this.formData.curriculumList.push({
                'picture': item.pictureTwo,
                'semester': item.semesterId.toString(),
                'orders': item.orders
              })
            }   
          })
        }
        // console.log(this.formData)
        this.formLoading.close()
      })
    },
    //上传照片
    uploadPic(e) {
      let that = this;
      let file = e;
      let param = new FormData(); //创建form对象
      param.append("file", file); //通过append向form对象添加数据
      that.$set(that.picNotice, 'text', '图片上传中...')
      that.$refs.pictureText.style.top = '5px'
      let config = {
        headers: {
          "Content-Type": "multipart/form-data"
        }
      }; //添加请求头
      fileUpload(param, config).then(response => {
        that.formData.picture = response.url;
        if(response.state == 'SUCCESS'){
          that.$set(that.picNotice, 'text', '图片上传成功')
          setTimeout(() => {
            that.$refs.pictureText.style.top = '-20px'
          }, 1000)
        } else {
          that.$refs.pictureText.style.top = '5px'
          that.$set(that.picNotice, 'text', '图片上传失败')
        }
      });
    },
    //上传头像
    async uploadAva(e,text) {
      let that = this;
      let file = e;
      let param = new FormData() //创建form对象
      // 设置提醒文字
      that.$set(that.avaNotice, 'text', text)
      that.$refs.avatarText.style.top = '0px';
      let config = {
        headers: {
          "Content-Type": "multipart/form-data"
        }
      }; //添加请求头
      // if(text == '正在截图...'){
      //   let res = false;
      //   param.append("base64", file)
      //   //截图
      //   await uploadBase64(param, config).then(response => {
      //     //有url
      //     if(response.state == 'SUCCESS'){
      //       that.temporaryUrl = response.url;
      //       that.$set(that.avaNotice, 'text', '头像上传成功')
      //       res = true
      //     }
      //     else {
      //       that.$set(that.avaNotice, 'text', '头像上传失败')
      //       res = false
      //     }
      //   })
      //   return Promise.resolve(res)
      // }
      //上传
      param.append("file", file)
      await fileUpload(param, config).then(response => {
      //有url
        if(response.state == 'SUCCESS'){
          that.temporaryUrl = response.url;
          that.previewUrl = that.temporaryUrl;
          that.avatarIsHttp = true;
          that.$set(that.avaNotice, 'text', '头像上传成功')
        }
        else {
          that.$set(that.avaNotice, 'text', '头像上传失败')
        }
        this.loading.close()
      }).catch(err=>{
        this.loading.close()
      })
    },
    // 昵称校验
    checkNickNameFn() {
      let that = this;
      if (that.formData.nickname === that.sNickname) return; // 昵称没变化的时候
      if (!that.formData.nickname) { // 有值的时候
        that.$set(that.nickData, "text", "");
        that.$set(that.nickData, "bool", false);
      } else {
        checkNickName(that.currentUser.type, "1", this.formData.nickname).then(
          data => {
            if (data) {
              that.$set(that.nickData, "bool", true);
              setTimeout(() => {
                that.$set(that.nickData, "text", "");
              }, 500)
            } else {
              that.$set(that.nickData, "text", "这个昵称太抢手了，换一个吧");
              that.$set(that.nickData, "bool", false);
            }
          }
        );
      }
    },
    success() {
      this.$message({
        message: '保存成功！',
        type: 'success',
        duration: 1500
      });
    },
    warning() {
      this.$message({
        message: '信息有误，请核对后再保存！',
        type: 'warning',
        duration: 1500
      });
    },
    ...mapActions(['setSupplyflag','setShowEmailBtn','setUser']),
    // 基本信息保存
    updateBasic(){
      if(this.needSupplyInfo!=0){
        this.updateAll()
        return
      }
      let that = this;
      if(this.birthFlow){
        this.warning()
        return;
      }
      if (!this.formData.sex) { // 判断姓别
        this.$refs.noticeText.style.top = '2px'
        this.warning()
        return
      } else {
        this.$refs.noticeText.style.top = '-15px'
      }
      this.$refs['basicForm'].validate(valid => {
        // console.log(valid)
        if(!valid){
          this.warning()
          return
        }
        this.formLoading = this.getLoading()
        userInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), that.cityId).then(data => {
          let setData = data.info;
          let y , m , d;
          if(this.birType == '0'){
            setData.birthType = '0';
            y = this.year.replace('年', '')
            m = this.month.replace('月', '')
            d = this.day.replace('日', '')
            setData.birthday = y + '/'+ m + '/'+ d;
            // console.log(this.getNearBirthDate(setData.birthType,setData.birthday))
          }
          else {
            setData.birthType = '1';
            y = this.year.replace(/[^\d]/g,'')
            let tmonth = new RegExp('闰')
            let res = tmonth.test(this.month)
            let index=0;
            let hasrun=false;
            for(let j=0;j<this.monthList.length;j++){
               hasrun= tmonth.test(this.monthList[j])
              if(hasrun){
                  index=j;
                  break;
              }
            }
            for(let i=0;i<this.monthList.length;i++){
              
              if(this.month == this.monthList[i]){
                if(res){
                  m = i;
                  break;
                }else{
                  if(hasrun){
                    if(index<i){
                      m = i;
                    break;
                    }else{
                      m = i+1;
                      break;
                    }
                  }else{
                     m = i+1;
                    break;
                  }
                  
                   
                }
               
              }
            }
            for(let i=0;i<this.dayList.length;i++){
              if(this.day == this.dayList[i]){
                d = i + 1;
                break;
              }
            }
            let cBirthday = '';
            if(res){
              cBirthday = calendar.lunar2solar(y,m,d,true)
            }else{
              cBirthday = calendar.lunar2solar(y,m,d,false)
            }
            setData.birthday = cBirthday.cYear + '/'+ cBirthday.cMonth + '/'+ cBirthday.cDay;
            // console.log(this.getNearBirthDate(setData.birthType,setData.birthday))
          }
          // console.log(this.avatarIsHttp,this.formData.avatar.replace('static', ''))
          if(!this.avatarIsHttp){
            setData.avatar = this.formData.avatar.replace('static', '')
          }else{
            setData.avatar = this.formData.avatar
          }
          // setData.avatar = this.formData.avatar.replace('static', '')
          setData.nickname = this.formData.nickname
          setData.sex = this.formData.sex
          setData.nearlyBirthday=this.getNearBirthDate(setData.birthType,setData.birthday)
          let certificateList = this.formData.certificateList
          
          let schoolTimetaleList = data.schoolTimetableList
          // console.log("basicTest:",setData)
          // console.log(this.getNearBirthDate(setData.birthType,setData.birthday))
          updateInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), setData, schoolTimetaleList,certificateList)
          .then(res => {
            let newAvatar = this.currentUser
            newAvatar.photo = that.formData.avatar
            that.setUser(newAvatar)
            that.success()
            that.getUserInfo()
          })
        }) 
        
      })
    },
    getNearBirthDate(birthType, time) {
    if (time != '') {
        var year = moment(time).format("YYYY");
        var month = moment(time).format("MM");
        var day = moment(time).format("DD");
        var mon = moment(time).format("M");
        var da = moment(time).format("D");
        var date = new Date;
        var yearNow = date.getFullYear();
        if (birthType == 0) {
            var solarDays = calendar.solarDays(yearNow, mon);
            if (da > solarDays) {//如果今年2月没有29，生日就为28
                return yearNow + "/" + month + "/" + solarDays;
            } else {
                return yearNow + "/" + month + "/" + day;
            }
        } else if (birthType == 1) {
            var LunarJson = calendar.solar2lunar(year, month, day);//将新历生日转成农历生日
            var leapMonth = calendar.leapMonth(yearNow);//判断今年闰月是几月
            var flag = false;
            if (leapMonth == LunarJson.lMonth) {
                flag = true;
            }
            var SolarJson = calendar.lunar2solar(yearNow, LunarJson.lMonth, LunarJson.lDay, flag);//判断今年农历生日是新历几号
            return SolarJson.cYear + '/' + SolarJson.cMonth + '/' + SolarJson.cDay;
        } else {
            return "";//非0，1情况，有些数据存在文字描述
        }
    } else {
        return "";
    }
  },
    // 联系信息保存
    updateContact(){
      if(this.needSupplyInfo!=0){
        this.updateAll()
        return
      }
      let that = this;
      let couId=this.$route.query.courseId
      if(couId===undefined){
        // 邮箱验证
          if(this.showEmailBtnBool){
            this.$set(this.emailCheck, 'className', 'red')
            this.$set(this.emailCheck, 'emailNotice', '请输入邮箱')
            this.$refs.emailDom.$el.children[0].style.border = '1px solid #f56c6c';
            this.warning()
            return
          }
      }else{
      courseDetail(couId).then(res=>{
          console.log(res)
          if(res.data.price==='0') return
          // 邮箱验证
          if(this.showEmailBtnBool){
            this.$set(this.emailCheck, 'className', 'red')
            this.$set(this.emailCheck, 'emailNotice', '请输入邮箱')
            this.$refs.emailDom.$el.children[0].style.border = '1px solid #f56c6c';
            this.warning()
            return
          }
      })
      }
      this.$refs['contactForm'].validate(valid => {
        if(!valid){
          this.warning()
          return
        }
        this.formLoading = this.getLoading()
        userInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), that.cityId).then(data => {
          let setData = data.info;
          setData.picture = that.formData.picture
          setData.name = that.formData.name
          setData.phone = that.formData.phone
          setData.idCard = that.formData.idCard
          setData.QQ = that.formData.QQ
          setData.email = that.formData.email
          let certificateList = data.certificateList
          let schoolTimetableList = data.schoolTimetableList
          // console.log("contactTest:",setData)
          updateInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), setData, schoolTimetableList,certificateList)
          .then(res => {
            this.success()
            this.getUserInfo()
          })
        })
      })
    },
    // 学校信息保存
    updateSchool(){
      if(this.needSupplyInfo!=0){
        this.updateAll()
        return
      }
      let that = this;
      this.$refs['schoolForm'].validate(valid => {
        if(!valid){
          this.warning()
          return
        }
        this.formLoading = this.getLoading()
        userInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), that.cityId).then(data => {
          let timetaleList = [], schoolTimetableList=[];
          // 课表
          for(let i=0;i<this.formData.curriculumList.length;i++){
            if(!timetaleList[this.formData.curriculumList[i].semester]){
              timetaleList[this.formData.curriculumList[i].semester]={
                "orders": this.formData.curriculumList[i].orders,
                "semesterId": this.formData.curriculumList[i].semester,
                "pictureOne": this.formData.curriculumList[i].picture,
                "pictureTwo": ""
              }    
            }else{
              timetaleList[this.formData.curriculumList[i].semester].pictureTwo = this.formData.curriculumList[i].picture
            }
          }
          for(let key in timetaleList){
            schoolTimetableList.push(timetaleList[key])
          }
          // console.log("schoolTimetableList:",schoolTimetableList)
          let certificateList = data.certificateList
          let setData = data.info;
          setData.city = that.formData.city
          setData.school = that.formData.school
          setData.college = that.formData.college
          setData.major = that.formData.major
          setData.grade = that.formData.grade
          setData.education = that.formData.education
          setData.projectCycle = that.formData.projectCycle
          // console.log("schoolTest:",setData)
          updateInfo(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), setData, schoolTimetableList,certificateList)
          .then(res => {
            this.success()
            this.getUserInfo()
          })
        })
      })
    },
    updateAll(){
      let that = this;
      let isPass = true;
      this.$refs['basicForm'].validate(valid => {
        if(!valid){
          isPass = false
        }
      })
      this.$refs['contactForm'].validate(valid => {
        if(!valid){
          isPass = false
        }
      })
      this.$refs['schoolForm'].validate(valid => {
        if(!valid){
          isPass = false
        }
      })
      
      // console.log("isPass:",isPass)
      if(this.needSupplyInfo==2 && this.formData.picture =='static/add.png'){
        this.$set(this.picNotice, 'bool', true)
        that.$set(that.picNotice, 'text', '请上传图片')
        this.$refs.pictureText.style.top = '5px'
        this.warning()
        return;
      }
      if (!this.formData.sex) { // 判断姓别
        this.$refs.noticeText.style.top = '2px'
        this.warning()
        return
      } else {
        this.$refs.noticeText.style.top = '-15px'
      }
      let couId=this.$route.query.courseId
      if(couId===undefined){
        // 邮箱验证
          if(this.showEmailBtnBool){
            this.$set(this.emailCheck, 'className', 'red')
            this.$set(this.emailCheck, 'emailNotice', '请输入邮箱')
            this.$refs.emailDom.$el.children[0].style.border = '1px solid #f56c6c';
            this.warning()
            return
          }
      }else{
      courseDetail(couId).then(res=>{
        console.log(res)
        if(res.data.price==='0') return
        if(this.showEmailBtnBool){
          this.$set(this.emailCheck, 'className', 'red')
          this.$set(this.emailCheck, 'emailNotice', '请输入邮箱')
          this.$refs.emailDom.$el.children[0].style.border = '1px solid #f56c6c';
          this.warning()
          return
        }
      })}
      if(isPass){
        let y , m , d;
        if(this.birType == '0'){
          that.formData.birthType = '0';
          y = this.year.replace('年', '')
          m = this.month.replace('月', '')
          d = this.day.replace('日', '')
          that.formData.birthday = y + '/'+ m + '/'+ d;
        }
        else {
          that.formData.birthType = '1';
          y = this.year.replace(/[^\d]/g,'')
          let tmonth = new RegExp('闰')
          let res = tmonth.test(this.month)
          for(let i=0;i<this.monthList.length;i++){
            if(this.month == this.monthList[i]){
              if(res){
                m = i;
                break;
              }
              m = i+1;
              break;
            }
          }
          for(let i=0;i<this.dayList.length;i++){
            if(this.day == this.dayList[i]){
              d = i + 1;
              break;
            }
          }
          let cBirthday = '';
          if(res){
            cBirthday = calendar.lunar2solar(y,m,d,true)
          }else{
            cBirthday = calendar.lunar2solar(y,m,d,false)
          }
          that.formData.birthday = cBirthday.cYear + '/'+ cBirthday.cMonth + '/'+ cBirthday.cDay;
        }
        if(!that.avatarIsHttp){
            that.formData.avatar = that.formData.avatar.replace('static', '')
          }
        // console.log("that.formData:",that.formData)
        this.formLoading = this.getLoading()
        checkInfoSave(that.currentUser.type, that.currentUser.cluesOrStuId.toString(), that.formData)
        .then(res => {
            this.success()
            this.setSupplyflag(0)
            let newAvatar = this.currentUser
            newAvatar.photo = that.formData.avatar
            this.setUser(newAvatar)
            this.formLoading.close()
            this.$router.replace({ path: 'payPage', query: { courseId: this.$route.query.courseId ,campus:this.$route.query.campus} })
        })
      }else{
        this.warning()
      }
    }
  },
  watch: {
    cityId() {
      this.getUserInfo();
    },
    // 监听性别是否有值
    sex() {
      this.$refs.noticeText.style.top = '-15px'
    }
  }
};
</script>
